package com.ict.web.controller.yzq;


import com.ict.common.core.domain.AjaxResult;
import com.ict.web.dto.ApprovalAddDto;
import com.ict.web.service.IApprovalService;
import com.ict.web.vo.ApprovalVo;
import com.ict.web.vo.OnLineVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.page.TableDataInfo;
import java.util.List;

/**
 * 审核Controller
 *
 * @author ruoyi
 * @date 2022-02-24
 */
@RestController
@RequestMapping("/web/approval")
@Api(tags = "审核-审批进度")
public class ApprovalController extends BaseController
{
    @Autowired
    private IApprovalService approvalService;

    /**
     * 审核
     */
    @PreAuthorize("@ss.hasPermi('web:approval:add')")
    @ApiOperation("审核")
    @PostMapping("/add")
    public AjaxResult add(@Validated @RequestBody ApprovalAddDto dto)
    {
        return toAjax(approvalService.insertApproval(dto));
    }

    /**
     * 上一次（最后一次）审核结果
     */
    @PreAuthorize("@ss.hasPermi('web:approval:add')")
    @ApiOperation("上一次（最后一次）审核结果")
    @PostMapping("/lastApprovalResult/{expertId}")
    public AjaxResult lastApprovalResult(@PathVariable("expertId")String expertId)
    {
        return AjaxResult.success(approvalService.lastApprovalResult(expertId));
    }

    /**
     * 在线预审
     */
    @ApiOperation("在线预审")
    @GetMapping("/onLinePreliminary")
    public List<OnLineVo> onLinePreliminary(@Param("proId") Long proId,@Param("createTime")String createTime)
    {
        return approvalService.onLinePreliminary(proId,createTime);
    }


    @ApiOperation("查询意见汇总审批意见")
    @GetMapping("/selectApprovalOpinion/{approvalId}")
    public AjaxResult selectApprovalOpinion(@PathVariable Long approvalId){
        return AjaxResult.success("操作成功",approvalService.getApprovalOpinion(approvalId));
    }
}
